import socket
import sys

host = "127.0.0.1"
port = 1234
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host,port))
s.listen(1)
conn, addr = s.accept()
print "connected to client @", addr
while 1:
    data = conn.recv(1024)
    if data == "stop":break
    conn.send(data)
    print data
    if not data:break
conn.close()



#while 1:
#    data = conn.recv(1024)
#    if not data: break
#    conn.send(data)
#    print data
#conn.close()
